package com.heima.feign.article;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.heima.article.dtos.ApArticleConfigDto;
import com.heima.article.dtos.ApArticleDto;
import com.heima.article.pojos.ApArticle;
import com.heima.article.pojos.ApArticleConfig;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.wemedia.vos.WmNewsStatisticsVo;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.Map;

/**
 * feign失败配置
 * 调用失败返回固定结果
 *
 * @author itheima
 */
@Component
public class ArticleClientFallback implements ArticleFeignClient {

    @PostMapping("save")
    @Override
    public ResponseResult save(ApArticleDto apArticleDto) {
        return ResponseResult.errorResult(AppHttpCodeEnum.CALL_INTERFACE_FAIL);
    }

    @PostMapping("/api/v1/article/getArticle")
    @Override
    public ResponseResult<ApArticle> getArticle(Long articleId) {
        return ResponseResult.errorResult(AppHttpCodeEnum.CALL_INTERFACE_FAIL);
    }

    @Override
    @PostMapping("/api/v1/article/getArticleConfig")
    public ResponseResult<ApArticleConfig> getArticleConfig(ApArticleConfigDto apArticleConfigDto) {
        return ResponseResult.errorResult(AppHttpCodeEnum.CALL_INTERFACE_FAIL);
    }

    @Override
    @PostMapping("/api/v1/article/updateArticleConfig")
    public ResponseResult updateArticleConfig(ApArticleConfigDto apArticleConfigDto) {
        return ResponseResult.errorResult(AppHttpCodeEnum.CALL_INTERFACE_FAIL);
    }

    @Override
    @PostMapping("/api/v1/article/updateArticleConfig")
    public ResponseResult<Map<String, Integer>> statistics(Integer authorId,
                                                           Date beginDate,
                                                           Date endDate) {
        return ResponseResult.errorResult(AppHttpCodeEnum.CALL_INTERFACE_FAIL);
    }

    @Override
    @GetMapping("/api/v1/article/articlePage")
    public ResponseResult<Page<WmNewsStatisticsVo>> articlePage(Date beginDate,
                                                                Date endDate,
                                                                Integer page,
                                                                Integer size,
                                                                Integer apUserId) {
        return ResponseResult.errorResult(AppHttpCodeEnum.CALL_INTERFACE_FAIL);
    }

}